public class ArabToRoman {
	public static String getRomanNumber(int arab){
		int[]    arabBase = {1000, 500, 100, 50, 10, 5, 1};
		String[] romeBase = {"M", "D", "C", "L", "X", "V", "I"};
		int result     = 0;
		int remainder  = 0;
		String resultRome = "";
		for(short i = 0; i<arabBase.length; i+=2) {
			result    = arab/arabBase[i];
		    remainder = arab%arabBase[i];
		    if(result>0 && result<4) {
		    	for(short j = 0; j<result; j++) {
		    		resultRome += romeBase[i];
		        }
		    }
		    else if(result>=4 && result<9) {
		    	for(short j=(short)result; j<5; j++) {
		    		resultRome += romeBase[i];
		    	}
		    	resultRome += romeBase[i-1];
		    	for(short j=5; j<result; j++) {
		    		resultRome += romeBase[i];
		    	}                
		    }
		    else if(result == 9) {
		    	resultRome += romeBase[i] + romeBase[i-2];
		    }
		    if(remainder==0) break;
		    	arab = remainder;
			}
	   return resultRome;
}
	
	
	public static void main(String[] args){
		System.out.println(getRomanNumber(2013));
	}
}
